﻿using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Vowei.Core.Models;
using System.Linq;
using System.ComponentModel.DataAnnotations;

namespace Vowei.Core.Models
{
    [DataContract]
    public class Comment : ITable, ICommentable
    {
        public Comment()
        {
            ID = Guid.NewGuid();
            CommentDate = DateTime.Now;
            Comments = new List<Comment>();
        }

        [DataMember]
        public Guid ID
        {
            get;
            set;
        }
                  
        [DataMember]
        public Guid PostId { get; set; }

        [DataMember]
        public string PostType { get; set; }

        /// <summary>
        /// 评论文本
        /// </summary>
        [DataMember]
        [Display(Name = "评论文本")]
        public string Text
        {
            get;
            set;
        }

        /// <summary>
        /// 评论用户
        /// </summary>
        [DataMember]
        [Display(Name = "评论用户")]
        public string User
        {
            get;
            set;
        }

        /// <summary>
        /// 评论时间
        /// </summary>
        [DataMember]
        [Display(Name = "评论时间")]
        public DateTime CommentDate
        {
            get;
            set;
        }

        /// <summary>
        /// 不支持对评论列出所有回复
        /// </summary>
        // TODO: 这种实现方式，对程序的性能影响应该很大，需要考虑改进方式
        [Display(Name = "相关评论")]
        // public virtual List<Comment> Comments { get; private set; }
        public virtual List<Comment> Comments { get; set; }
    }

}